package com.efast.dmom.aps.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.aps.bean.PlanOrder;
import com.efast.dmom.aps.bean.PlanOrderAdjustQueryCondition;
import com.efast.dmom.aps.bean.PlanOrderAdjustQueryData;
import com.efast.dmom.aps.bean.PlanOrderBean;
import com.efast.dmom.aps.bean.ResultBean;
import com.efast.dmom.aps.service.PlanOrderService;

@Controller
@RequestMapping("/planOrder")
public class PlanOrderController {
	@Autowired
	private PlanOrderService planOrderService;
	
	
	
	@RequestMapping(value = "/mergePlanOrder")
	public @ResponseBody ResultBean mergePlanOrder(@RequestBody List<PlanOrder> orderList) {
		
		return  planOrderService.mergePlanOrder(orderList);
		
	}
	@RequestMapping(value = "/splitPlanOrder")
	public @ResponseBody ResultBean splitPlanOrder(@RequestBody PlanOrderBean planOrderBean) {
		
		List<Double> qty = planOrderBean.getQty();
		PlanOrder planOrder = planOrderBean.getPlanOrder();
		return  planOrderService.splitPlanOrder(planOrder, qty);
		
	}
	@RequestMapping(value = "/rollbackPlanOrder")
	public @ResponseBody ResultBean rollbackPlanOrder(@RequestBody PlanOrderBean planOrderBean) {
		PlanOrder planOrder = planOrderBean.getPlanOrder();
		String type = planOrderBean.getReorganizationType();
		return  planOrderService.rollbackPlanOrder(planOrder, type);
		
	}
	@RequestMapping(value = "/holdPlanOrder")
	public @ResponseBody ResultBean holdPlanOrder(@RequestBody PlanOrderBean planOrderBean) {
		List<PlanOrder> orderList = planOrderBean.getListPlanOrder();		
		String reason = planOrderBean.getReason();
		return  planOrderService.holdPlanOrder(orderList,reason);
		
	}
	@RequestMapping(value = "/unholdPlanOrder")
	public @ResponseBody ResultBean unholdPlanOrder(@RequestBody PlanOrderBean planOrderBean) {
		List<PlanOrder> orderList = planOrderBean.getListPlanOrder();		
		String reason = planOrderBean.getReason();
		return  planOrderService.unholdPlanOrder(orderList,reason);
		
	}

	@RequestMapping(value = "/auditPlanOrder")
	public @ResponseBody ResultBean auditPlanOrder(@RequestBody List<PlanOrder> orderList) {
		
		return  planOrderService.auditPlanOrder(orderList);
		
	}
	@RequestMapping(value = "/unAuditPlanOrder")
	public @ResponseBody ResultBean unAuditPlanOrder(@RequestBody  PlanOrderBean planOrderBean) {
		List<PlanOrder> orderList = planOrderBean.getListPlanOrder();		
		String reason = planOrderBean.getReason();
		return  planOrderService.unAuditPlanOrder(orderList, reason);
		
	}
	
	@RequestMapping(value = "/getDataByPlanOrderAdjust")
	public @ResponseBody PlanOrderAdjustQueryData getDataByPlanOrderAdjust(@RequestBody PlanOrderAdjustQueryCondition planOrderAdjustQueryCondition) {
		
		return  planOrderService.getDataByPlanOrderAdjust(planOrderAdjustQueryCondition);
		
	}

}
